package com.glasses.primework;

import javax.faces.bean.ManagedBean;
import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.LineChartModel;
import org.primefaces.model.chart.LineChartSeries;

@ManagedBean
public class CartesianBean {
    private LineChartModel model;
    
    public CartesianBean() {
        model = new LineChartModel();
        
        LineChartSeries boys = new LineChartSeries();
        boys.setFill(true);
        boys.setLabel("Boys");
        boys.set("2004", 120);
        boys.set("2005", 100);
        boys.set("2006", 44);
        boys.set("2007", 150);
        boys.set("2008", 25);
        
        LineChartSeries girls = new LineChartSeries();
        girls.setFill(true);
        girls.setLabel("Girls");
        girls.set("2004", 52);
        girls.set("2005", 60);
        girls.set("2006", 110);
        girls.set("2007", 90);
        girls.set("2008", 120);
        
        model.addSeries(boys);
        model.addSeries(girls);
        model.setTitle("Area Chart");
        model.setLegendPosition("ne");
        model.setStacked(true);
        model.setShowPointLabels(true);
        model.getAxis(AxisType.X).setLabel("Years");
        Axis yAxis = model.getAxis(AxisType.Y);
        yAxis.setLabel("Births");
        yAxis.setMin(0);
        yAxis.setMax(300);
    }
    
    public CartesianChartModel getModel() {
        return model;
    }
}